package eu.ydp.mathplayer.editor.view;

import com.google.gwt.event.dom.client.ClickEvent;
import com.google.gwt.event.dom.client.ClickHandler;
import com.google.gwt.event.dom.client.MouseDownEvent;
import com.google.gwt.event.dom.client.MouseDownHandler;
import com.google.gwt.user.client.ui.FlowPanel;
import com.google.gwt.user.client.ui.Panel;
import com.google.gwt.user.client.ui.ScrollPanel;

import eu.ydp.mathplayer.editor.FocusScrollPanel;
import eu.ydp.mathplayer.editor.controller.ActionSocket;

public class SandboxView extends FlowPanel {

	private FocusScrollPanel mathPanel;
	
	private ActionSocket actionSocket;
	
	public SandboxView(){
		setStyleName("math-editor-sandbox-container");
		
		mathPanel = new FocusScrollPanel();
		mathPanel.setStyleName("math-editor-sandbox-panel");
		add(mathPanel);
		
		mathPanel.addClickHandler(new ClickHandler() {
			
			@Override
			public void onClick(ClickEvent event) {
				if (actionSocket != null)
					actionSocket.setFocus();
			}
		});
		
	}

	public void init(ActionSocket actionSocket){
		this.actionSocket = actionSocket;
	}
	
	public Panel getSandboxOwner(){
		return mathPanel;
	}
}
